﻿using System;
using System.Text.RegularExpressions;

public class Example
{
    public static void Main()
    {
        int i = 0;
        string pattern = "try";
        Console.WriteLine("Введите строку и нажмите ENTER");
        string input = Console.ReadLine();
        Match match = Regex.Match(input, pattern);
        while (match.Success)
        {
            Console.WriteLine("{0} found as position {1}.", match.Value, match.Index);
            i = i + 1;
            match = match.NextMatch();

        }
        Console.Write(i);
        Console.ReadLine();
    }
}
